Rates Information


In [1]:
import pandas as pd
import oandapyV20
from oandapyV20 import API
import oandapyV20.endpoints.pricing as pricing
import configparser

In [2]:
config = configparser.ConfigParser()
config.read('../config/config_v20.ini')
accountID = config['oanda']['account_id']
access_token = config['oanda']['api_key']
api = API(access_token=access_token)

In [3]:
params ={
          "instruments": "EUR_USD,EUR_JPY"
        }

In [4]:
r = pricing.PricingInfo(accountID=accountID, params=params)

In [5]:
rv = api.request(r)

In [6]:
print(r.response)


{'prices': [{'type': 'PRICE', 'instrument': 'EUR_USD', 'time': '2017-01-31T06:56:33.045012160Z', 'bids': [{'liquidity': 10000000.0, 'price': '1.06933'}, {'liquidity': 10000000.0, 'price': '1.06931'}], 'status': 'tradeable', 'quoteHomeConversionFactors': {'positiveUnits': '1.41913000', 'negativeUnits': '1.41934000'}, 'closeoutAsk': '1.06952', 'unitsAvailable': {'default': {'long': '3293816', 'short': '3294766'}, 'reduceOnly': {'long': '0', 'short': '0'}, 'openOnly': {'long': '3293816', 'short': '3294766'}, 'reduceFirst': {'long': '3293816', 'short': '3294766'}}, 'closeoutBid': '1.06929', 'asks': [{'liquidity': 10000000.0, 'price': '1.06948'}, {'liquidity': 10000000.0, 'price': '1.06950'}], 'tradeable': True}, {'type': 'PRICE', 'instrument': 'EUR_JPY', 'time': '2017-01-31T06:56:31.757929252Z', 'bids': [{'liquidity': 1000000.0, 'price': '121.415'}, {'liquidity': 2000000.0, 'price': '121.414'}, {'liquidity': 5000000.0, 'price': '121.413'}, {'liquidity': 10000000.0, 'price': '121.411'}], 'status': 'tradeable', 'quoteHomeConversionFactors': {'positiveUnits': '0.01249719', 'negativeUnits': '0.01250109'}, 'closeoutAsk': '121.439', 'unitsAvailable': {'default': {'long': '3293546', 'short': '3295161'}, 'reduceOnly': {'long': '0', 'short': '0'}, 'openOnly': {'long': '3293546', 'short': '3295161'}, 'reduceFirst': {'long': '3293546', 'short': '3295161'}}, 'closeoutBid': '121.411', 'asks': [{'liquidity': 1000000.0, 'price': '121.435'}, {'liquidity': 2000000.0, 'price': '121.436'}, {'liquidity': 5000000.0, 'price': '121.437'}, {'liquidity': 10000000.0, 'price': '121.439'}], 'tradeable': True}]}

In [7]:
pd.DataFrame(r.response['prices'])


Out[7]:
asks bids closeoutAsk closeoutBid instrument quoteHomeConversionFactors status time tradeable type unitsAvailable
0 [{'liquidity': 10000000.0, 'price': '1.06948'}... [{'liquidity': 10000000.0, 'price': '1.06933'}... 1.06952 1.06929 EUR_USD {'positiveUnits': '1.41913000', 'negativeUnits... tradeable 2017-01-31T06:56:33.045012160Z True PRICE {'default': {'long': '3293816', 'short': '3294...
1 [{'liquidity': 1000000.0, 'price': '121.435'},... [{'liquidity': 1000000.0, 'price': '121.415'},... 121.439 121.411 EUR_JPY {'positiveUnits': '0.01249719', 'negativeUnits... tradeable 2017-01-31T06:56:31.757929252Z True PRICE {'default': {'long': '3293546', 'short': '3295...

In [8]:
r.response['prices']


Out[8]:
[{'asks': [{'liquidity': 10000000.0, 'price': '1.06948'},
   {'liquidity': 10000000.0, 'price': '1.06950'}],
  'bids': [{'liquidity': 10000000.0, 'price': '1.06933'},
   {'liquidity': 10000000.0, 'price': '1.06931'}],
  'closeoutAsk': '1.06952',
  'closeoutBid': '1.06929',
  'instrument': 'EUR_USD',
  'quoteHomeConversionFactors': {'negativeUnits': '1.41934000',
   'positiveUnits': '1.41913000'},
  'status': 'tradeable',
  'time': '2017-01-31T06:56:33.045012160Z',
  'tradeable': True,
  'type': 'PRICE',
  'unitsAvailable': {'default': {'long': '3293816', 'short': '3294766'},
   'openOnly': {'long': '3293816', 'short': '3294766'},
   'reduceFirst': {'long': '3293816', 'short': '3294766'},
   'reduceOnly': {'long': '0', 'short': '0'}}},
 {'asks': [{'liquidity': 1000000.0, 'price': '121.435'},
   {'liquidity': 2000000.0, 'price': '121.436'},
   {'liquidity': 5000000.0, 'price': '121.437'},
   {'liquidity': 10000000.0, 'price': '121.439'}],
  'bids': [{'liquidity': 1000000.0, 'price': '121.415'},
   {'liquidity': 2000000.0, 'price': '121.414'},
   {'liquidity': 5000000.0, 'price': '121.413'},
   {'liquidity': 10000000.0, 'price': '121.411'}],
  'closeoutAsk': '121.439',
  'closeoutBid': '121.411',
  'instrument': 'EUR_JPY',
  'quoteHomeConversionFactors': {'negativeUnits': '0.01250109',
   'positiveUnits': '0.01249719'},
  'status': 'tradeable',
  'time': '2017-01-31T06:56:31.757929252Z',
  'tradeable': True,
  'type': 'PRICE',
  'unitsAvailable': {'default': {'long': '3293546', 'short': '3295161'},
   'openOnly': {'long': '3293546', 'short': '3295161'},
   'reduceFirst': {'long': '3293546', 'short': '3295161'},
   'reduceOnly': {'long': '0', 'short': '0'}}}]